package com.zeng.ssm.service.config;

import org.jeecg.modules.jmreport.config.oss.JmReportUploadConfig;
import org.jeecg.modules.jmreport.config.oss.dto.Path;
import org.springframework.beans.factory.InitializingBean;

/**
 * 描述信息
 *
 * @author zengwanlin
 * @date 2022-03-12T1:57
 */
//@Configuration("jimuReportUploadConfig")
//@PropertySource(value = {"classpath:jimu.properties"}, encoding = "UTF-8")
public class JimuReportUploadConfig extends JmReportUploadConfig implements InitializingBean {

    private Path path;

    //@Value("${jeecg.path.upload}")
    private String pathUpload;

    //@Value("${jeecg.path.webapp}")
    private String pathWebapp;

    //@Value("${jeecg.uploadType}")
    private String uploadType;

    @Override
    public Path getPath() {
        if (path == null) {
            System.out.println("JimuReport设置Path值");
            path = new Path();
            path.setUpload("${user.home}/nbms_jmreport/files/jmreport/upload");
            path.setWebapp("${user.home}/nbms_jmreport/files/jmreport/webapp");
        }
        return path;
    }

    @Override
    public void setPath(Path path) {
        this.path = path;
    }

    @Override
    public String getUploadType() {
        return uploadType;
    }

    @Override
    public void setUploadType(String uploadType) {
        this.uploadType = uploadType;
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        if (path == null) {
            System.out.println("设置Path值");
            path = new Path();
            path.setUpload(pathUpload);
            path.setWebapp(pathWebapp);
        }
    }

    @Override
    public String toString() {
        return "JimuReportUploadConfig{" +
                "path=" + path +
                ", pathUpload='" + pathUpload + '\'' +
                ", pathWebapp='" + pathWebapp + '\'' +
                ", uploadType='" + uploadType + '\'' +
                '}';
    }
}
